<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>渐变</title>
  </head>
  <body>
    <div class="edition">
      <h3 class="discover">渐变颜色</h3>
    </div>
    <span class="text">文字渐变</span>
    <div class="box">背景图作为文字背景色</div>
    <style>
      .discover {
        /* 非文本需要添加此属性 */
        display: inline-block;
        font-size: 32px;
        font-weight: 500;
        line-height: 45px;
        /* 要给字体添加渐变色效果，可以使用CSS中的background-clip和-webkit-text-fill-color属性搭配使用 */
        background: linear-gradient(
          270deg,
          #5099f7 0%,
          rgba(80, 172, 247, 0.7534) 25%,
          rgba(80, 88, 247, 0.3836) 62%,
          #f7507f 100%
        );
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }

      /* 方案二 */
      .text {
        background: linear-gradient(to right, #ff0000, #0000ff, #00ff00);
        background-clip: text;
        -webkit-background-clip: text;
        -webkit-text-fill-color: transparent;
      }

      /* 方案三 */
      .box {
        display: inline-block;
        background-image: url("./img/triangle.png");
        background-clip: text;
        -webkit-background-clip: text;
        color: transparent;
        font-size: 68px;
        font-weight: bold;
      }
    </style>
  </body>
</html>
